#include "UserRegionUtil.h"
#include <stack>
#include <QtCore/QLineF>

void NewUserRegionParam::reset() {
    userRegionWidgetType = -1;
    polygonParam = GeoPolygonParam();
}

UserRegionDrawProperty NewUserRegionParam::getCurrentPaintProperty() const {

    if (userRegionWidgetType == RS_USER_REGION_POLYGON_TYPE) {
        return polygonParam.paintProy;
    }
    else {
        return UserRegionDrawProperty();
    }
}


static QLineF moveLine(const QPointF& from, const QPointF& to, double dist)
{
#ifndef M_PI 
#define M_PI 3.1415926
#endif
    double  r = atan2(to.x() - from.x(), to.y() - from.y()) + M_PI / 2.0;
    double  x = sin(r)*dist;
    double  y = cos(r)*dist;
    double  x1 = from.x() + x;
    double y1 = from.y() + y;
    double x2 = to.x() + x;
    double y2 = to.y() + y;
    QLineF line(x1, y1, x2, y2);
    return line;
}
